home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / inn1.000 / inn1.4sec-linux-src.tar / inn / iftrue.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1993-01-29  |  552b  |  25 lines

  1. #! /bin/sh
  2. ##  $Revision: 1.3 $
  3. ##  Perform a test(1) and execute a command string if the test is true;
  4. ##  otherwise exit 0.  Usage:
  5. ##    testit <test> <command>
  6. ##  On some systems (those with a /bin/sh from BSD4.2), the following
  7. ##  line in a Makefile will always fail:
  8. ##    if [ ! -f x ] ; then echo No x -- stop. ; exit 1 ; else exit 0 ; fi
  9. case $# in
  10. 2)
  11.     ;;
  12. *)
  13.     echo "Can't perform test:  wrong number of arguments." 1>&2
  14.     exit 1
  15.     ;;
  16. esac
  17. TEST="$1"
  18. COMMAND="$2"
  19.  
  20. if eval "test ${TEST}" ; then
  21.     eval "${COMMAND}"
  22.     exit $?
  23. fi
  24. exit 0
  25.